package com.usian.controller;

import com.usian.pojo.TbItemParam;
import com.usian.service.ItemParamService;
import com.usian.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/service/itemParam")
public class ItemParamController {
    @Autowired
    private ItemParamService itemParamService;

    @RequestMapping("deleteItemParamById")
    Integer deleteItemParamById(@RequestParam("id") Long id){
        return itemParamService.deleteItemParamById(id);
    }

    /**
     * 商品规格模板添加接口
     *
     * @param itemCatId
     * @param paramData
     * @return
     */
    @RequestMapping("insertItemParam")
    Integer insertItemParam(@RequestParam("itemCatId") Long itemCatId,@RequestParam("paramData") String paramData){
        return itemParamService.insertItemParam(itemCatId,paramData);
    }

    /**
     * 规格模板查询接口
     *
     * @return
     */
    @RequestMapping("selectItemParamAll")
    PageResult selectItemParamAll(@RequestParam Integer pages,
                                  @RequestParam Integer rows){
        return itemParamService.selectItemParamAll(pages,rows);
    }

    /**
     * 根据商品分类 ID 查询规格参数模板
     */
    @RequestMapping("/selectItemParamByItemCatId")
    TbItemParam selectItemParamByItemCatId(@RequestParam Long itemCatId) {
        return this.itemParamService.selectItemParamByItemCatId(itemCatId);
    }
}